package com.YxyBackMange.Service.web.impl;

import com.YxyBackMange.Entity.Ware.WareAppointment;
import com.YxyBackMange.Entity.Ware.WareOrderInfo;
import com.YxyBackMange.Mapper.web.WebOrderInfoMapper;
import com.YxyBackMange.Service.web.WebOrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @outhor 路♥克
 * 2017-12-16 4:27
 */
@Service
public class WebOrderInfoServiceImpl implements WebOrderInfoService {

    @Autowired
    private WebOrderInfoMapper webOrderInfoMapper;


    @Override
    public WareOrderInfo insertService(WareOrderInfo o) {
        Date currentTime = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
        String dateString = formatter.format(currentTime);
        int i = (int) ((Math.random() * 9 + 1) * 1000);
        o.setOrderNum(dateString+i);
        o.setCreateTime(currentTime);
        o.setStateId(6);
        o.setOperateTime(currentTime);
        if (webOrderInfoMapper.insertSelective(o)>0) {
            return o;
        }
        return null;
    }

    @Override
    public WareOrderInfo updateService(WareOrderInfo o) {
        return null;
    }

    @Override
    public WareOrderInfo insert(WareOrderInfo o) {
        return null;
    }

    @Override
    public WareOrderInfo update(WareOrderInfo o) {
        return null;
    }

    @Override
    public WareOrderInfo delete(WareOrderInfo o) {
        if (webOrderInfoMapper.delete(o)>0) {
            return o;
        }
        return null;
    }

}
